﻿#region 命名空间

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WinnerCMS.BLL;
using WinnerCMS.Common;
using WinnerCMS.Model;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.Common
{
    [Access("OP")]
    public partial class Tags : WebFactory.PageBase
    {
        private byte ModelId;

        protected void Page_Load(object sender, EventArgs e)
        {
            this.ModelId = byte.Parse(Request.QueryString["ModelId"]);
            if (!IsPostBack)
            {
                BindList(1);
            }
        }

        public void BindList(int PageNo)
        {
            this.GV_List.EmptyDataTemplate = GetTemplate(this);

            var pp = new PagingParam();
            pp.PageNo = PageNo;
            pp.PageSize = this.PageNavigation1.PageSize;

            var strTitle = "Tags管理";
            var TagName = "";
            if (this.txtKeyWord.Text.Trim().Length > 0)
            {
                TagName = this.txtKeyWord.Text;
                strTitle += string.Format(" → 搜索“{0}”", this.txtKeyWord.Text.Trim());
                Title = strTitle;

                this.lblPath.Text = string.Format("{0} → <a href='Tags.aspx?ModelId={1}'>Tags管理</a>→ 搜索“{2}”",
                    ModelManage.GetModelName(this.ModelId), this.ModelId, this.txtKeyWord.Text.Trim());
            }
            else
            {
                Title = strTitle;

                this.lblPath.Text = string.Format("{0} → <a href='Tags.aspx?ModelId={1}'>Tags管理</a>",
                    ModelManage.GetModelName(this.ModelId), this.ModelId);
            }


            this.GV_List.DataSource = new TagsManage().BindList(this.ModelId, TagName, pp);
            this.GV_List.DataBind();

            this.PageNavigation1.RecordCount = pp.RecordCount;
        }


        protected void PageNavigation1_PageChanging(object src, WebControls.PageChangingEventArgs e)
        {
            BindList(e.NewPageIndex);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindList(1);
        }
    }
}